"""

  - 不允许有重复元素，如果添加重复元素，则会自动过滤，可以进行交集、并集的运算
  - 无序不可重复
  - 与dict类似，是一组key的集合（不存储value）

"""
# 集合的创建
s = set()
print(s,type(s))

s  = {1,2,3,4,True,3.14}
print(s,type(s))

s1 = set([1,2,3,3,2,1]) # list --> set
print(s1,type(s1))

s2 = set((1,2,3,4))  # tuple --> set
print(s2,type(s2))

s3 = set("123") # str --> set
print(s3,type(s3))

s4 = set({1:"a","b":2}) # dict --> set
print(s4,type(s4))

# in
print(1 in s4)

# len
print(len(s4))

# del
# del s4

print("*" * 20)

# 集合的遍历
for i  in s4:
    print(i)

# 集合常用方法
s.remove(1)
print(s)
s.update({2,3,4,5})
print(s)
s.add(6)
print(s)

# 交集、并集
s5 = {5,6,7,8,9}
s6 = {8,9,10}
print("交集",s5 & s6)
print("并集",s5 | s6)

# 列表去重
score = [70,80,80,70,60,100]
ss = set(score)
print(ss)

# 统计各个分数都有几个学生
for i in ss:
    t =  score.count(i)
    print("分数为%d的学生有%d个人" %(i,t))